package tjs.study.notes.dotest.mongo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoTransactionManager;
import org.springframework.data.mongodb.core.MongoTemplate;

@Configuration
public class MongoTransactionConfig {
    @Bean
    public MongoTransactionManager transactionManager(MongoTemplate dbFactory) {
        return new MongoTransactionManager(dbFactory.getMongoDatabaseFactory());
    }

//    @Primary
//    @Bean(name = "TjdDemoMongoTemplate")
//    public MongoTemplate getMongoTemplate() throws Exception {
//        MongoClient mongoClient = MongoClients.create("mongodb://localhost:27017/tjs_demo?retryWrites=false");
//        return new MongoTemplate(mongoClient, "test");
//    }

}
